//
//  UIBarButtonItem+CustomItem.m
//  01-WeiBoProject
//
//  Created by lin on 16/2/26.
//  Copyright © 2016年 www.lampbrother.net/ios/. All rights reserved.
//

#import "UIBarButtonItem+CustomItem.h"

@implementation UIBarButtonItem (CustomItem)

+ (UIBarButtonItem *)customBarButtonItemWithImageName:(NSString *)imageName hightImageName:(NSString *)hightImageName target:(id)target selector:(SEL)selecotor {
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed: imageName] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed: hightImageName] forState:UIControlStateHighlighted];
    
    btn.frame = CGRectMake(0, 0, btn.currentImage.size.width, btn.currentImage.size.height);
    [btn addTarget:target action:selecotor forControlEvents:UIControlEventTouchUpInside];
    
    // 减少不必要的代码 减少重复代码
    UIBarButtonItem *backBarItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    
    return backBarItem;

}

@end
